package com.kedacom.freedomLabel.model.db.dao;

import android.arch.persistence.room.Dao;
import android.arch.persistence.room.Delete;
import android.arch.persistence.room.Insert;
import android.arch.persistence.room.OnConflictStrategy;
import android.arch.persistence.room.Query;
import android.arch.persistence.room.Update;

import com.kedacom.freedomLabel.model.bean.Template;

import java.util.List;

/**
 * @author licheng
 * @since 2019/12/6 15:57
 */
@Dao
public interface TemplateDao extends IDao<Template> {

    @Override
    @Query("SELECT COUNT(0) FROM Template")
    int count();

    @Override
    @Update
    void update(Template template);

    @Override
    @Insert(onConflict = OnConflictStrategy.FAIL)
    long save(Template category);

    @Override
    @Insert(onConflict = OnConflictStrategy.FAIL)
    long[] save(List<Template> data);

    @Override
    @Query("SELECT * FROM Template")
    List<Template> get();

    @Override
    @Query("SELECT * FROM Template WHERE type =:type")
    List<Template> get(String type);

    @Override
    @Query("SELECT * FROM Template WHERE type =:type OR type =:param2")
    List<Template> get(String type, String param2);

    @Override
    @Delete
    void delete(Template data);

    @Override
    @Query("DELETE FROM Template")
    void delete();

    @Override
    @Query("DELETE FROM Template WHERE type =:type")
    void delete(String type);
}
